<?php
class Admin_Model_SupportOnline extends Zend_Db_Table_Abstract{
	protected $_name = 'SupportOnline';
	
	public function getAllSupportOnline()
	{
		$select = $this->select()->setIntegrityCheck(false)
						->from(array('n' => 'SupportOnline'),'*')
						->joinLeft(array('c'=> 'username'),'n.ym = c.ym');
		$result = $this->fetchAll($select);
		return $result;
	}
	
	public function updateSupportOnline($id,$username,$ym)
	{
		$row = $this->find($id)->current();
		if ($row)
		{
			$row->SupportOnline_username = $username;
			$row->SupportOnline_ym = $ym;
			
			$row->save();
		}
	}
	
	public function addSupportOnline($username,$ym)
	{
		$row = $this->createRow();
		$row->SupportOnline_username = $username;
		$row->SupportOnline_ym = $ym;
		
		$row->save();
		$id = $this->_db->lastInsertId();
		return $id;
	}
	
	public function deleteSupportOnline($newsid)
	{
		$row = $this->find($supportonlineid)->current();
		if ($row)
		{
			$row->delete();
			return true;
		}
		else
		{
			throw new Zend_Exception("Could not find SupportOnline with id = ".$SupportOnlineid);
		}
	}
}